package com.samh.openrower2;



import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.Handler;
import android.os.Binder;
import android.util.Log;


public class SensorService extends Service {
	
	private static final String TAG = "SensorService";
	
	private StrokeSensor mStrokeSensor;
	private SpeedSensor mSpeedSensor;
	private HeartRateSensor mHeartRateSensor;
	private LocalBinder mBinder = new LocalBinder();
	private Handler mHandler = new Handler();
	

	public class LocalBinder extends Binder {
		
		SensorService getService() {
			return SensorService.this;
		}
	}
	
	@Override
	public IBinder onBind(Intent intent) {
		// TODO Auto-generated method stub
		return mBinder;
	}
	
	
	@Override
	public void onStart(Intent intent, int startId) {
		// TODO Auto-generated method stub
		super.onStart(intent, startId);
		
		mStrokeSensor = new StrokeSensor(this);
		
		mStrokeSensor.startListener();
		
		mSpeedSensor = new SpeedSensor();
		
		mSpeedSensor.startListener(this);
		
		mHeartRateSensor = new HeartRateSensor();
		
		mHeartRateSensor.start(this);
		
		Log.d(TAG,"SENSOR SERVICE STARTED");
		
	}
	
	public SpeedSensor getSpeedSensor() {
		return mSpeedSensor;
	}
	
	public StrokeSensor getStrokeSensor() {
		return mStrokeSensor;
	}
	
	public HeartRateSensor getHeartRateSensor() {
		return mHeartRateSensor;
	}
	
	public void reset() {
		
		mSpeedSensor.resetTotalDistance();
		
		mSpeedSensor.resetLocationsCount();
		
		mStrokeSensor.resetStrokeCont();
	}
	
	
}
